<template>
	<view class="body">
				
		<view class="wrap">
<!-- 			<view class="row">
				<u-row  class="">
							<u-col span="4">
								<p>客户</p>
								<u-toast ref="uToast" />
							</u-col>
							<u-col span="4">
								<p>到账金额</p>
							</u-col>
							<u-col span="4">
								<p>到账时间</p>
							</u-col>
				</u-row>
			</view>
			<view class="row">
				<u-row class="">
							<u-col span="4">
								<p>戴维</p>
							</u-col>
							<u-col span="4">
								<p>2000元</p>
							</u-col>
							<u-col span="4">
								<p>2020-8-10</p>
							</u-col> 
				</u-row>
			</view> -->
		</view> 
		<view class="row">
			<u-row  class="">
				<u-col span="2" >
					<u-icon name="rmb"  color="#2979ff" ></u-icon>
				</u-col>
				<u-col span="6">
					<u-input v-model="num" :type="number" placeholder="请输入提现金额" />
				</u-col>
			</u-row>
			<u-row>
				<u-col>
					<u-col span="12" >
						可提现金额：{{commission}}
					</u-col>
				</u-col>
			</u-row>
		</view>
		<view class="baocun" @click="withdrawal()">
			提现
		</view>
		
	</view>
</template>



<script>
	export default {
		data() {
			return {
				commission:"",
				num:'',
				agent_id:"",
				sub:'微信零钱',
				title: '提现到',
				array: ['交通银行', '陕西信合', '招商银行', '中国银行']
			};
		},
		onReady() {
			this.Getageid()
		},
		methods:{
			Getageid(){
				var that=this
				wx.getStorage({
					key:"agent_id",
					success(res) {
						that.agent_id=res.data
						console.log(res.data);
						that.getMonry()
					}
				})				
			},
			getMonry(){
				let that = this
				this.$flyio.get('v1.agent/info', {
				       agent_id: that.agent_id
				      }).then((ret) => {
						  console.log("业务员请求返回");
				       // console.log(ret.data.commission)
					   that.commission=ret.data.commission
				      })
				      .catch((e) => {
				       console.log(e)
				      })
			},
			withdrawal(){
				var that=this
				if(!this.num){
					this.$refs.uToast.show({
										title: '请输入提现金额',
										type: 'warning',
									})
					return false
				}
				this.$flyio.post('v1.Agent/customerApply', {
						agent_id: that.agent_id,
						amount:that.num,
					}).then((ret) => {
						console.log(ret.code);
						if(ret.code==0){
							that.$refs.uToast.show({
								title: '提现发起成功',
								type: 'success',
								url: '/pages/shop/banlv'
							})
						}
						else{
							this.$refs.uToast.show({
								title: ret.msg,
								type: "error",
							})
						}
					})
					.catch((e) => {
						console.log(e)
					})
			}
		}

	};
</script>

<style scoped lang="scss">
	.body{
		text-align: center;
		height: 100%;
		width: 100%;
		padding: 24rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		background-color: $gary;
	}
		.wrap {
			padding: 24rpx;
		}

	.row{
		background-color: $f;
		width: 100%;
		height: 80rpx;
		line-height: 80rpx;
		box-sizing: border-box;
		text-align: center;
	}
	.baocun{
		justify-self: flex-end;
	}
</style>
